<?php
/**
 * 根对象
 *
 * @package framework
 * @version $Id$
 * @since 0.1
 */
class IObject {
	private $refId;
	private $time;
	private $microtime;
	
	/**
	 * 取得引用标识ID
	 *
	 * @return string
	 * @since 0.1
	 */
	public function refId() {
		if ($this->refId == null) {
			$this->refId = str_replace(".", "_",  uniqid(__CLASS__ . "_", true));
			IRegistry::singleton()->addRef($this);
		}
		return $this->refId;
	}
	

	public function dump($return = false) {
		if ($return) {
			return print_r($this, true);
		}
		echo "\n<pre>\n" . $this->dump(true) . "\n</pre>\n";
	}
	
	protected function _time($refresh = false) {
		if ($this->time == null || $refresh) {
			$this->time = time();
		}
		return $this->time;
	}
	
	protected function _microtime($refresh = false) {
		if ($this->microtime == null || $refresh) {
			$this->microtime = microtime(true);
		}
		return $this->microtime;
	}
	
	protected function _log($msg, $level = ILog::LOG_DEBUG) {
		ILog::singleton()->log($msg, $level);
	}
}

?>